<?php
  //引入系统配置文件
  include_once('config/init.php');
  include_once('check.php');

  // 先查找出所有部门的信息
  $sql = "SELECT * FROM {$pre_}department";
  $deplist = all($sql);

  // var_dump($deplist);
  // exit;

  if($_POST){
    // var_dump($_POST);
    // exit;

    // 组装数据
    $data = [
      'name' => isset($_POST['name']) ? trim($_POST['name']) : '',
    ];
    // var_dump($data);
    // exit;

    $res = add("department",$data);
    // 判断是否添加成功
    if($res){
      Notice("添加部门成功","DepList.php");
      exit;
    }else{
      Notice("添加部门失败");
      exit;
    }
}
?>

<!DOCTYPE html>
<html lang="en">
  <head>
   
     <!-- 引入公共样式 -->
     <?php include_once('meta.php');?>
  </head>

  <body>

   <!-- 引入头部 -->
   <?php include_once('header.php');?>

    <!-- 引入菜单 -->
    <?php include_once('menu.php');?>
    

    <div class="content">
        <div class="header">
            <h1 class="page-title">添加部门</h1>
        </div>
        <ul class="breadcrumb">
            <li><a href="index.php">Home</a> <span class="divider">/</span></li>
            <li class="active">添加部门</li>
        </ul>

        <div class="container-fluid">
            <div class="row-fluid">
                    
                <div class="btn-toolbar">
                    <button class="btn btn-primary" onClick="location='DepList.php'"><i class="icon-list"></i> 返回部门管理</button>
                  <div class="btn-group">
                  </div>
                </div>

                <div class="well">
                    <div id="myTabContent" class="tab-content">
                      <div class="tab-pane active in" id="home">
                        <form method="post" enctype="multipart/form-data">
                            <label>部门名称</label>
                            <input type="text" name="name" required value="" placeholder="请输入部门名称" class="input-xxlarge" >
                            
                            <label></label>
                            <input class="btn btn-primary" type="submit" value="提交" />
                        </form>
                      </div>
                  </div>
                </div>

                <div class="modal small hide fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                  <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h3 id="myModalLabel">Delete Confirmation</h3>
                  </div>
                  <div class="modal-body">
                    
                    <p class="error-text"><i class="icon-warning-sign modal-icon"></i>Are you sure you want to delete the user?</p>
                  </div>
                  <div class="modal-footer">
                    <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
                    <button class="btn btn-danger" data-dismiss="modal">Delete</button>
                  </div>
                </div>
                
                <footer>
                    <hr>
                    <p>&copy; 2017 <a href="#" target="_blank">copyright</a></p>
                </footer>
                    
            </div>
        </div>
    </div>
  </body>
</html>